//
//  QAViewController.m
//  CYWFrame
//
//  Created by Macx on 2017/9/26.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "QAViewController.h"
#import "CCZSegementController2.h"
#import "QAZoneViewController.h"
#import "QAExpertsViewController.h"
#import "RealNameContentViewController.h"

@interface QAViewController ()

@end

@implementation QAViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self buildUI];
}

#pragma mark ==========构建UI==========
- (void)buildUI {
    
    self.view.backgroundColor = kWhiteColor;
    
    self.navigationItem.title = @"问答";
    
    // 导航栏左右按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"认证" style:UIBarButtonItemStyleDone target:self action:@selector(pushRealClick)];
    
    NSArray *vcArr = @[[[QAZoneViewController alloc] init], [[QAExpertsViewController alloc] init]];
    NSArray *nameArr = @[@"问答专区", @"专家在线"];
    
    CCZSegementController2 *segement = [CCZSegementController2 segementControllerWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) titles:nameArr];
    
    [segement setSegementViewControllers:vcArr];
    
    segement.style = CCZSegementStyleDefault;
    [segement setSegementTintColor:UIMainColorRGB];
    [self.view addSubview:segement.view];
    [self addChildViewController:segement];
    [segement selectedNavAtIndex:^(NSInteger index) {
        NSLog(@"index %ld",index);
    }];
    
}

- (void)pushRealClick {
    RealNameContentViewController *realNameVC = [[RealNameContentViewController alloc] init];
    realNameVC.isExperts = 0;
    realNameVC.uid = [GetUserDefaule(USERINFO) valueForKey:@"user_id"];
    [self.navigationController pushViewController:realNameVC animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
